package com.tanhua;

import com.tanhua.template.HuanXinTemplate;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class HuanxinDemo {

    //应用的授权--注册--发信息--交好友（获取token）
    /*@Test
    public void test(){
        // 1 模拟浏览器发送post请求
        RestTemplate restTemplate = new RestTemplate();
        //2 指定地址传递参数3个
        String url="http://a1.easemob.com/1172210114153525/demo/token";
        Map<String,String> map=new HashMap();
        map.put("grant_type","client_credentials");
        map.put("client_id","YXA6fnvNvj0mTWWxSR9wD32vwA");
        map.put("client_secret","YXA6iWKFDPnv_8LLPS85xaR-WfHZ2a8");
        ResponseEntity<Map> mapResponseEntity = restTemplate.postForEntity(url, map, Map.class);
        Map resultMap = mapResponseEntity.getBody();
        String token =(String) resultMap.get("access_token");
        System.out.println(token);
    }*/

    @Autowired
    private HuanXinTemplate huanXinTemplate;

    @Test //注册新用户到环信 账号是1 密码是123456
    public void test1(){
        huanXinTemplate.register(1L); //底层会调用授权获取token的
    }
}
